package controller;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import model.VO.DishVO;
import service.Impl.DishServiceImpl;
import util.ResultUtil;

import java.io.IOException;

@WebServlet("/admin/dish/get")
public class DishByIdController extends HttpServlet {
    //按id查询菜品
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id=Integer.parseInt(req.getParameter("id"));
        DishServiceImpl ds=new DishServiceImpl();
        DishVO dishVO=ds.find(id);
        String json= ResultUtil.getJSON(dishVO);
        resp.getWriter().println(json);
    }
}
